package org.springside.modules.webservice;


/**
 * 统一的带错误码与错误信息定义的WebService专用异常. 
 * 
 * 在SOAP中将转化为与语言无关的fault节点,如CXF中将转为:
 *    <soap:Fault>
 *       <faultcode>soap:Server</faultcode>
 *       <faultstring>101:userId为空</faultstring>
 *       <detail>
 *          <ns1:FaultException xmlns:ns1="http://miniservice.examples.springside.org">
 *             <code>101</code>
 *             <faultMessage>userId为空</faultMessage>
 *          </ns1:FaultException>
 *       </detail>
 *    </soap:Fault>
 *
 * 在web service client根据自身的异常机制转化为相应的类.
 * 
 * @author calvin
 */
public class FaultException extends RuntimeException {

	private static final long serialVersionUID = -3643320023232370152L;

	private String code;

	private String faultMessage;

	/**
	 * @param code 错误代码
	 * @param faultMessage 错误信息
	 */
	public FaultException(String code, String faultMessage) {
		super(code + ":" + faultMessage);
		this.code = code;
		this.faultMessage = faultMessage;
	}

	public FaultException(String faultMessage) {
		super(faultMessage);
		this.faultMessage = faultMessage;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getFaultMessage() {
		return faultMessage;
	}

	public void setFaultMessage(String faultMessage) {
		this.faultMessage = faultMessage;
	}
}
